import request from '@/config/axios'
import type {Dayjs} from 'dayjs';

/** 部门协同-任务列信息 */
export interface ProjectTask {
    id: number; // ID
    templateId?: number; // 模板id
    typeId?: number; // 模板类型id
    projectId: number; // 项目id
    taskName?: string; // 任务名称
    finishState: string; // 完成状态
    executeState: string; // 执行状态
    executeUser: string; // 执行人
    deadline: string | Dayjs; // 截止时间
    content: string; // 任务内容
    priority: string; // 优先级
    label: string; // 标签
    taskFile: string; // 关联文件
    assistUser: string; // 协助人
    executeFinishTime: string | Dayjs; // 执行完成时间
    score: string; // 评分
    scoreDesc: string; // 评分描述
    remark: string; // 备注
}

// 部门协同-任务列 API
export const ProjectTaskApi = {

    getSynergyNumber: async () => {
        return await request.post({url: `/synergy/project-task/getSynergyNumber`})
    },

    // 查询部门协同-任务列分页
    getProjectTaskPage: async (params: any) => {
        return await request.get({url: `/synergy/project-task/page`, params})
    },

    // 查询部门协同-任务列详情
    getProjectTask: async (id: number) => {
        return await request.get({url: `/synergy/project-task/get?id=` + id})
    },

    // 新增部门协同-任务列
    createProjectTask: async (data: ProjectTask) => {
        return await request.post({url: `/synergy/project-task/create`, data})
    },

    // 修改部门协同-任务列
    updateProjectTask: async (data: ProjectTask) => {
        return await request.put({url: `/synergy/project-task/update`, data})
    },

    // 删除部门协同-任务列
    deleteProjectTask: async (id: number) => {
        return await request.delete({url: `/synergy/project-task/delete?id=` + id})
    },

    /** 批量删除部门协同-任务列 */
    deleteProjectTaskList: async (ids: number[]) => {
        return await request.delete({url: `/synergy/project-task/delete-list?ids=${ids.join(',')}`})
    },

    // 导出部门协同-任务列 Excel
    exportProjectTask: async (params) => {
        return await request.download({url: `/synergy/project-task/export-excel`, params})
    }
}
